package com.tico.translatereditor.service.impl;

import com.tico.common.service.impl.AbstractService;
import com.tico.common.utils.BaseQuery;
import com.tico.common.utils.QueryResult;
import com.tico.translatereditor.domain.Kafka;
import com.tico.translatereditor.mapper.KafkaMapper;
import com.tico.translatereditor.service.KafkaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 */
@Service
public class KafkaServiceImpl extends AbstractService<Kafka> implements KafkaService {


   @Autowired
   KafkaMapper kafkaMapper;

   @Override
   public Kafka findById(Serializable id) {
     return kafkaMapper.findById(id);
   }
    @Override
    public int update(Kafka param){
       return kafkaMapper.update(param);
    }
    @Override
    public int insertBatch(List<Kafka> kafkas) {
      return kafkaMapper.insertBatch(kafkas);
    }

    @Override
    public int insert(Kafka kafka) {
      return kafkaMapper.insert(kafka);
    }
    @Override
    public List<Kafka > findByNamedParamList(Map<String,Object> param){
        return kafkaMapper.findByNamedParamList(param);
    }

    @Override
    public int delete(Serializable id) {
      return kafkaMapper.delete(id);
    }

    @Override
    public int remove(Serializable id) {
      return kafkaMapper.remove(id);
    }

    @Override
    public QueryResult<Kafka> findPageInfo(BaseQuery baseQuery) {
        QueryResult<Kafka> result = new QueryResult<Kafka>();
        result.setQuery(baseQuery);
        Map
        <String, Object> params = result.getQuery().build();
        Integer amount = this.kafkaMapper.countPageInfo(params);
        result.setTotalRecord(amount);
        if (amount == 0) {
        return result;
        }
        List<Kafka> list = kafkaMapper.findPageInfo(params);
        if (!CollectionUtils.isEmpty(list)) {
        result.setResultList(list);

        }
        return result;
    }
}
